<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
            	<div class="dataTables_filter" id="searchFromDiv">
            		<input type="hidden"  name="parent" id="parent" value="${parent}"/>
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" data-btn-type="add">新增</button>
                        <button type="button" class="btn btn-default" data-btn-type="edit">编辑</button>
                        <button type="button" class="btn btn-default" data-btn-type="delete">删除</button>
                    </div>
                </div>
            
                <div class="box-body">
                    <table id="${nodeName}_table" class="table table-bordered table-striped table-hover">
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    var ${nodeName}Table, winId = "${nodeName}Win";
    $(function (){
    	${nodeName}Table = new CommonTable("${nodeName}_table", "DF_${nodeId}", "searchFromDiv", null);
    	
    	
    	$("button[data-btn-type]").click(function () {
            var action = $(this).data("btn-type");
            var rowId = ${nodeName}Table.getSelectedRowId();
            switch (action) {
                case "add":
                    modals.openWin({
                        winId: winId,
                        title: '新增',
                        width: "900px",
                        url: basePath + "/dform/edit?parent=${parent}&node=${nodeId}"
                    })
                    break;
                case "edit":
                    if (!rowId) {
                        modals.info('请选择要编辑的行');
                        return false;
                    }
                    modals.openWin({
                        winId: winId,
                        title: '编辑',
                        width: '900px',
                        url: basePath + "/dform/edit?id=" + rowId + "&parent=${parent}&node=${nodeId}"
                    });
                    break;
                case 'delete':
                    if (!rowId) {
                        modals.info('请选择要删除的行');
                        return false;
                    }
                    modals.confirm("是否要删除该行数据？", function () {
                        ajaxPost(basePath + "/dform/delete/" + rowId+"?node=${nodeId}", null, function (data) {
                            if (data.success) {
                            	${nodeName}Table.reloadRowData();
                            } else {
                                modals.info("数据被引用，不可删除！");
                            }
                        });
                    })
                    break;
            }
        })
    	    	
    })
    
   	function fnRenderOperator(value,type,rowObj,oSetting){
    	console.info(rowObj.fileids);
		var oper="<a href='#' onclick='previewImg(\""+rowObj.fileids+"\")'><i class='fa'>查看现场图片</i></a>";
		return oper;
	}
    
    function previewImg(id){
    	modals.openWin({
            winId: 'showimg',
            title: '查看现场图',
            width: '900px',
            url: basePath + "/dform/showimg?files=" + id
        });
    }

</script>